package cn.kgc.itrip.biz.controller;

import cn.kgc.itrip.beans.dto.Dto;
import cn.kgc.itrip.beans.vo.ItripImageVO;
import cn.kgc.itrip.beans.vo.ItripLabelDicVO;
import cn.kgc.itrip.beans.vo.hotelroom.ItripHotelRoomVO;
import cn.kgc.itrip.beans.vo.hotelroom.SearchHotelRoomVO;
import cn.kgc.itrip.biz.service.HotelRoomService;
import cn.kgc.itrip.biz.service.LabelDicService;
import cn.kgc.itrip.utils.DtoUtil;
import cn.kgc.itrip.utils.ErrorCode;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/api/hotelroom")
public class HotelRoomController {

    @Resource
    private LabelDicService labelDicService;
    @Resource
    private HotelRoomService hotelRoomService;

    /**
     * 酒店详情-查询房间图片
     * @param roomId
     * @return
     */
    @RequestMapping(value = "/getimg/{roomId}",method = RequestMethod.GET)
    public Dto doGetImg(@PathVariable Long roomId){
        try {
            List<ItripImageVO> vos = hotelRoomService.getImg(roomId);
            return DtoUtil.returnDataSuccess(vos);
        } catch (Exception e) {
            e.printStackTrace();
            return DtoUtil.returnFail("查询房间图片失败！", ErrorCode.BIZ_UNKNOWN);
        }
    }
    /**
     * 酒店详情-房间列表查询
     * @param vo
     * @return
     */
    @RequestMapping(value = "/queryhotelroombyhotel",method = RequestMethod.POST)
    public Dto doQueryHotelRoomByHotel(@RequestBody SearchHotelRoomVO vo){
        try {
            List<List<ItripHotelRoomVO>> vos = hotelRoomService.queryHotelRoomByHotel(vo);
            return DtoUtil.returnDataSuccess(vos);
        } catch (Exception e) {
            e.printStackTrace();
            return DtoUtil.returnFail("查询酒店房间失败！", ErrorCode.BIZ_UNKNOWN);
        }
    }
    /**
     * 酒店详情-床型列表
     * @return
     */
    @RequestMapping(value = "/queryhotelroombed",method = RequestMethod.GET)
    public Dto doQueryHotelRoomBed(){
        try {
            List<ItripLabelDicVO> vos = labelDicService.queryHotelRoomBed();
            return DtoUtil.returnDataSuccess(vos);
        } catch (Exception e) {
            e.printStackTrace();
            return DtoUtil.returnFail("查询床型失败！", ErrorCode.BIZ_UNKNOWN);
        }
    }
}
